{extend name='public/base' /}
{block name='content'}
{include file='public/content_header' /}
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <div class="box box-primary">
                <!-- 表单头部 -->
                <div class="box-header with-border">
                    <div class="btn-group">
                        <a class="btn flat btn-sm btn-default BackButton">
                            <i class="fa fa-arrow-left"></i>
                            返回
                        </a>
                    </div>
                </div>
                <!-- 表单 -->
                <form id="dataForm" class="form-horizontal dataForm" action="" method="post" enctype="multipart/form-data" onkeydown="if(event.keyCode===13){return false;}">
                    <!-- 表单字段区域 -->
                    <div class="box-body">
                        <div class="form-group">
    <label for="insure" class="col-sm-2 control-label">保险名字</label>
    <div class="col-sm-10 col-md-4">
        <input id="insure" name="insure" value="{$data.insure|default=''}" placeholder="请输入保险名字" type="text" class="form-control field-text">
    </div>
</div>
<div class="form-group">
    <label for="status" class="col-sm-2 control-label">是否启用</label>
    <div class="col-sm-10 col-md-4">
    <input class="input-switch"  id="status" value="1" {if(!isset($data) ||$data.status==1)}checked{/if} type="checkbox" />
    <input class="switch field-switch" placeholder="是否启用" name="status" value="{$data.status|default='1'}" hidden />
    </div>
</div>

<script>
    $('#status').bootstrapSwitch({
        onText: "是",
        offText: "否",
        onColor: "success",
        offColor: "danger",
        onSwitchChange: function (event, state) {
            $(event.target).closest('.bootstrap-switch').next().val(state ? '1' : '0').change();
        }
    });
</script>
                    </div>
                    <!-- 表单底部 -->
                    <div class="box-footer">
                        {:token()}
                        <div class="col-sm-2">
                        </div>
                        <div class="col-sm-10 col-md-4">
                            {if !isset($data)}
                                <div class="btn-group pull-right">
                                    <label class="createContinue">
                                        <input type="checkbox" value="1" id="_create" name="_create"
                                                                   title="继续添加数据">继续添加</label>
                                </div>
                             {/if}
                            <div class="btn-group">
                                <button type="submit" class="btn flat btn-info dataFormSubmit">
                                    保存
                                </button>
                            </div>
                            <div class="btn-group">
                                <button type="reset" class="btn flat btn-default dataFormReset">
                                    重置
                                </button>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</section>
<script>
    /** 表单验证 **/
    $('#dataForm').validate({
        rules: {
                'insure': {
        required: true,
    },
    'status': {
        required: true,
    },

        },
        messages: {
                'insure': {
        required: "保险名字不能为空",
    },
    'status': {
        required: "是否启用不能为空",
    },

        }
    });
</script>
{/block}